<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Linux服务网络连通性诊断：ping命令完全指南</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
            line-height: 1.6;
            color: #333;
            background-color: #f5f5f5;
        }
        
        .container {
            display: flex;
            min-height: 100vh;
            max-width: 1400px;
            margin: 0 auto;
        }
        
        .editor {
            width: 50%;
            background-color: #282c34;
            color: #abb2bf;
            padding: 20px;
            overflow-y: auto;
            font-family: 'Courier New', Courier, monospace;
            resize: none;
            border: none;
            outline: none;
        }
        
        .preview {
            width: 50%;
            background-color: white;
            padding: 40px;
            overflow-y: auto;
        }
        
        @media (max-width: 768px) {
            .container {
                flex-direction: column;
            }
            .editor, .preview {
                width: 100%;
                height: 50vh;
            }
        }
        
        /* Markdown 样式 */
        .preview h1, .preview h2, .preview h3 {
            margin-top: 1.5em;
            margin-bottom: 0.5em;
            font-weight: 600;
            color: #2c3e50;
        }
        
        .preview h1 {
            font-size: 2.5rem;
            border-bottom: 2px solid #eee;
            padding-bottom: 0.3em;
        }
        
        .preview h2 {
            font-size: 2rem;
            border-bottom: 1px solid #eee;
            padding-bottom: 0.3em;
        }
        
        .preview h3 {
            font-size: 1.5rem;
        }
        
        .preview p {
            margin-bottom: 1em;
        }
        
        .preview pre {
            background-color: #f6f8fa;
            padding: 16px;
            border-radius: 6px;
            overflow: auto;
            margin-bottom: 1em;
        }
        
        .preview code {
            font-family: 'Courier New', Courier, monospace;
            background-color: #f6f8fa;
            padding: 2px 4px;
            border-radius: 3px;
        }
        
        .preview pre code {
            background-color: transparent;
            padding: 0;
        }
        
        .preview blockquote {
            border-left: 4px solid #ddd;
            padding-left: 1em;
            margin-left: 0;
            margin-bottom: 1em;
            color: #666;
        }
        
        .preview table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 1em;
        }
        
        .preview table, .preview th, .preview td {
            border: 1px solid #ddd;
        }
        
        .preview th, .preview td {
            padding: 8px 12px;
            text-align: left;
        }
        
        .preview th {
            background-color: #f2f2f2;
        }
        
        .preview tr:nth-child(even) {
            background-color: #f9f9f9;
        }
        
        .preview ul, .preview ol {
            margin-left: 1.5em;
            margin-bottom: 1em;
        }
        
        .preview li {
            margin-bottom: 0.5em;
        }
        
        .preview strong {
            font-weight: 600;
        }
        
        .preview hr {
            border: 0;
            height: 1px;
            background-color: #eee;
            margin: 2em 0;
        }
        
        /* 滚动条样式 */
        ::-webkit-scrollbar {
            width: 8px;
            height: 8px;
        }
        
        ::-webkit-scrollbar-track {
            background: #f1f1f1;
        }
        
        ::-webkit-scrollbar-thumb {
            background: #888;
            border-radius: 4px;
        }
        
        ::-webkit-scrollbar-thumb:hover {
            background: #555;
        }
    </style>
</head>
<body>
    <div class="container">
        <textarea id="markdownEditor" class="editor" readonly></textarea>
        <div id="htmlPreview" class="preview"></div>
    </div>

    <!-- 引入marked.js库 -->
    <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
    
    <script>
        // 设置marked选项
        marked.setOptions({
            breaks: true,
            gfm: true,
            tables: true,
            headerIds: true,
            sanitize: false,
            highlight: function(code, lang) {
                // 简单的代码高亮处理
                if (lang && lang === 'bash') {
                    // 基本的bash语法高亮
                    return code
                        .replace(/\b(ping|ifconfig|ip|route|grep|awk|traceroute|mtr|tcpdump|nmap|arping|sudo|apt-get|yum|ls|cd|cat|echo|grep)\b/g, '<span style="color:#d73a49">$1</span>')
                        .replace(/#[^\n]*/g, '<span style="color:#6a737d">$0</span>')
                        .replace(/\-[a-z]/g, '<span style="color:#005cc5">$0</span>');
                }
                return code;
            }
        });
        
        // 读取Markdown文件并渲染
        async function loadAndRenderMarkdown() {
            try {
                // 读取neu_net.md文件内容
                const response = await fetch('neu_net.md');
                if (!response.ok) {
                    throw new Error('无法加载Markdown文件');
                }
                
                const markdownText = await response.text();
                
                // 设置编辑器内容
                document.getElementById('markdownEditor').value = markdownText;
                
                // 渲染为HTML
                const htmlContent = marked.parse(markdownText);
                document.getElementById('htmlPreview').innerHTML = htmlContent;
                
                // 添加平滑滚动到锚点的功能
                document.querySelectorAll('a[href^="#"]').forEach(anchor => {
                    anchor.addEventListener('click', function(e) {
                        e.preventDefault();
                        const targetId = this.getAttribute('href');
                        const targetElement = document.querySelector(targetId);
                        if (targetElement) {
                            targetElement.scrollIntoView({ behavior: 'smooth' });
                        }
                    });
                });
                
            } catch (error) {
                console.error('加载Markdown文件时出错:', error);
                document.getElementById('htmlPreview').innerHTML = 
                    '<div style="color: red; padding: 20px;">无法加载Markdown文件: ' + error.message + '</div>';
            }
        }
        
        // 页面加载完成后执行
        document.addEventListener('DOMContentLoaded', function() {
            loadAndRenderMarkdown();
        });
    </script>
</body>
</html>